import * as C from "/Frame/ControllerBase";
import { test1 } from "/App/middleware/index";
import { Decorate as vIndex, Validate } from '/App/validate/index';


export default class index implements C.ControllerBase {
    _middleware = [test1('666')];
    _method = [C.Method.GET, C.Method.POST];



    async index(ctx: C.Context) {

        // return ctx.view('index/index', { yoyo: '你好YoyoThink' });
        // return ctx.json({ yoyo: '你好YoyoThink' });
        // console.log(await ctx.upload('file',true));
        console.log(JSON.stringify(ctx.request.body));
        return {ec:200};
    }

    @vIndex('name', 'query')
    async test(ctx: C.Context) {
        return 'test';
    }

    #test2(ctx: C.Context) {
        try {
            Validate('name').check(ctx.query);
        } catch (error: any) {
            throw [7000, error.message];
        }
        return 'test2';
    }
}